package com.demo.java.disruptor.netty.client;

import com.demo.java.disruptor.netty.common.TranslatorData;
import com.demo.java.disruptor.netty.common.DisruptorFactory;
import com.demo.java.disruptor.netty.common.DisruptorFactory.Producer;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class ClientMessageHandler extends ChannelInboundHandlerAdapter {
    private Producer producer;
    public void channelActive(ChannelHandlerContext channel) throws Exception {
        producer = DisruptorFactory.createProducer();
        System.out.println("client active");
    }

    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        TranslatorData data = (TranslatorData) msg;
        this.producer.sendData(ctx, data, true);
    }
}
